(define (cont-frac fn fd k)
    (define (iter result count)        
        (let ( 
                (n (fn k))
                (d (fd k)) 
            )
            (display "result=")
            (display result)
            (newline)
            ; (display "count=")
            ; (display count)
            ; (newline)
            ; (display "d=")
            ; (display d)
            (newline)
            (if (> count 1) 
                (iter (/ n (+ d result)) (- count 1))
                result
            )
        )
    )
    (iter (/  (fn k) (fd k)) k)    
)
(define (tan x)
    (define (calc1 k)
        (cont-frac 
            (lambda (i)
                (if (= i 1)
                    x
                    (* x x)
                )
            ) 
            (lambda (i) 
                (- (* 2.0 i) 1.0)
            ) 
            k
        )    
    )
    (calc1 50)
)
(display (tan 90.0)) 
    
(exit)